/*

  Copyright (c) 2014 Tobias Platen
  Copyright (c) 2008 MUSIC TECHNOLOGY GROUP (MTG)
  UNIVERSITAT POMPEU FABRA

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include "sekai/hzosc.h"


double ifft_scale_sinc = 512.000000;
double ifft_tab_sinc[4096] = {
  0.000000, 0.000001, 0.000001, 0.000002,
  0.000002, 0.000003, 0.000004, 0.000004,
  0.000005, 0.000006, 0.000007, 0.000007,
  0.000008, 0.000009, 0.000010, 0.000011,
  0.000011, 0.000012, 0.000013, 0.000014,
  0.000015, 0.000016, 0.000017, 0.000018,
  0.000019, 0.000020, 0.000021, 0.000022,
  0.000024, 0.000025, 0.000026, 0.000027,
  0.000028, 0.000030, 0.000031, 0.000032,
  0.000034, 0.000035, 0.000036, 0.000038,
  0.000039, 0.000041, 0.000042, 0.000044,
  0.000045, 0.000047, 0.000049, 0.000050,
  0.000052, 0.000054, 0.000055, 0.000057,
  0.000059, 0.000061, 0.000063, 0.000065,
  0.000067, 0.000069, 0.000071, 0.000073,
  0.000075, 0.000077, 0.000079, 0.000081,
  0.000083, 0.000086, 0.000088, 0.000090,
  0.000093, 0.000095, 0.000098, 0.000100,
  0.000103, 0.000105, 0.000108, 0.000110,
  0.000113, 0.000116, 0.000119, 0.000122,
  0.000124, 0.000127, 0.000130, 0.000133,
  0.000136, 0.000139, 0.000143, 0.000146,
  0.000149, 0.000152, 0.000156, 0.000159,
  0.000162, 0.000166, 0.000169, 0.000173,
  0.000177, 0.000180, 0.000184, 0.000188,
  0.000192, 0.000195, 0.000199, 0.000203,
  0.000207, 0.000212, 0.000216, 0.000220,
  0.000224, 0.000228, 0.000233, 0.000237,
  0.000242, 0.000246, 0.000251, 0.000256,
  0.000260, 0.000265, 0.000270, 0.000275,
  0.000280, 0.000285, 0.000290, 0.000295,
  0.000300, 0.000306, 0.000311, 0.000316,
  0.000322, 0.000328, 0.000333, 0.000339,
  0.000345, 0.000350, 0.000356, 0.000362,
  0.000368, 0.000375, 0.000381, 0.000387,
  0.000393, 0.000400, 0.000406, 0.000413,
  0.000420, 0.000426, 0.000433, 0.000440,
  0.000447, 0.000454, 0.000461, 0.000468,
  0.000476, 0.000483, 0.000490, 0.000498,
  0.000506, 0.000513, 0.000521, 0.000529,
  0.000537, 0.000545, 0.000553, 0.000561,
  0.000570, 0.000578, 0.000586, 0.000595,
  0.000604, 0.000612, 0.000621, 0.000630,
  0.000639, 0.000649, 0.000658, 0.000667,
  0.000677, 0.000686, 0.000696, 0.000706,
  0.000715, 0.000725, 0.000735, 0.000745,
  0.000756, 0.000766, 0.000777, 0.000787,
  0.000798, 0.000809, 0.000820, 0.000831,
  0.000842, 0.000853, 0.000864, 0.000876,
  0.000887, 0.000899, 0.000911, 0.000923,
  0.000935, 0.000947, 0.000959, 0.000972,
  0.000984, 0.000997, 0.001009, 0.001022,
  0.001035, 0.001048, 0.001062, 0.001075,
  0.001089, 0.001102, 0.001116, 0.001130,
  0.001144, 0.001158, 0.001172, 0.001187,
  0.001201, 0.001216, 0.001231, 0.001246,
  0.001261, 0.001276, 0.001291, 0.001307,
  0.001323, 0.001338, 0.001354, 0.001370,
  0.001387, 0.001403, 0.001420, 0.001436,
  0.001453, 0.001470, 0.001487, 0.001504,
  0.001522, 0.001539, 0.001557, 0.001575,
  0.001593, 0.001611, 0.001630, 0.001648,
  0.001667, 0.001686, 0.001705, 0.001724,
  0.001743, 0.001763, 0.001783, 0.001802,
  0.001822, 0.001843, 0.001863, 0.001884,
  0.001904, 0.001925, 0.001946, 0.001967,
  0.001989, 0.002010, 0.002032, 0.002054,
  0.002076, 0.002099, 0.002121, 0.002144,
  0.002167, 0.002190, 0.002213, 0.002236,
  0.002260, 0.002284, 0.002308, 0.002332,
  0.002357, 0.002381, 0.002406, 0.002431,
  0.002456, 0.002482, 0.002507, 0.002533,
  0.002559, 0.002585, 0.002612, 0.002638,
  0.002665, 0.002692, 0.002720, 0.002747,
  0.002775, 0.002803, 0.002831, 0.002859,
  0.002888, 0.002917, 0.002946, 0.002975,
  0.003004, 0.003034, 0.003064, 0.003094,
  0.003124, 0.003155, 0.003186, 0.003217,
  0.003248, 0.003280, 0.003312, 0.003344,
  0.003376, 0.003408, 0.003441, 0.003474,
  0.003507, 0.003541, 0.003575, 0.003609,
  0.003643, 0.003677, 0.003712, 0.003747,
  0.003782, 0.003818, 0.003854, 0.003890,
  0.003926, 0.003963, 0.003999, 0.004036,
  0.004074, 0.004111, 0.004149, 0.004187,
  0.004226, 0.004265, 0.004304, 0.004343,
  0.004382, 0.004422, 0.004462, 0.004503,
  0.004543, 0.004584, 0.004626, 0.004667,
  0.004709, 0.004751, 0.004794, 0.004836,
  0.004879, 0.004923, 0.004966, 0.005010,
  0.005054, 0.005099, 0.005144, 0.005189,
  0.005234, 0.005280, 0.005326, 0.005372,
  0.005419, 0.005466, 0.005513, 0.005561,
  0.005609, 0.005657, 0.005706, 0.005755,
  0.005804, 0.005853, 0.005903, 0.005953,
  0.006004, 0.006055, 0.006106, 0.006158,
  0.006210, 0.006262, 0.006314, 0.006367,
  0.006421, 0.006474, 0.006528, 0.006583,
  0.006637, 0.006692, 0.006748, 0.006804,
  0.006860, 0.006916, 0.006973, 0.007030,
  0.007088, 0.007146, 0.007204, 0.007263,
  0.007322, 0.007381, 0.007441, 0.007501,
  0.007562, 0.007623, 0.007684, 0.007746,
  0.007808, 0.007870, 0.007933, 0.007996,
  0.008060, 0.008124, 0.008188, 0.008253,
  0.008318, 0.008384, 0.008450, 0.008517,
  0.008583, 0.008651, 0.008718, 0.008786,
  0.008855, 0.008924, 0.008993, 0.009063,
  0.009133, 0.009204, 0.009275, 0.009346,
  0.009418, 0.009490, 0.009563, 0.009636,
  0.009710, 0.009784, 0.009858, 0.009933,
  0.010009, 0.010084, 0.010161, 0.010237,
  0.010315, 0.010392, 0.010470, 0.010549,
  0.010628, 0.010707, 0.010787, 0.010868,
  0.010948, 0.011030, 0.011111, 0.011194,
  0.011276, 0.011360, 0.011443, 0.011527,
  0.011612, 0.011697, 0.011783, 0.011869,
  0.011955, 0.012043, 0.012130, 0.012218,
  0.012307, 0.012396, 0.012485, 0.012575,
  0.012666, 0.012757, 0.012849, 0.012941,
  0.013033, 0.013126, 0.013220, 0.013314,
  0.013409, 0.013504, 0.013600, 0.013696,
  0.013793, 0.013890, 0.013988, 0.014086,
  0.014185, 0.014285, 0.014385, 0.014485,
  0.014586, 0.014688, 0.014790, 0.014893,
  0.014996, 0.015100, 0.015204, 0.015309,
  0.015414, 0.015521, 0.015627, 0.015734,
  0.015842, 0.015950, 0.016059, 0.016169,
  0.016279, 0.016390, 0.016501, 0.016613,
  0.016725, 0.016838, 0.016952, 0.017066,
  0.017180, 0.017296, 0.017412, 0.017528,
  0.017646, 0.017763, 0.017882, 0.018001,
  0.018120, 0.018240, 0.018361, 0.018483,
  0.018605, 0.018727, 0.018851, 0.018975,
  0.019099, 0.019224, 0.019350, 0.019477,
  0.019604, 0.019732, 0.019860, 0.019989,
  0.020119, 0.020249, 0.020380, 0.020512,
  0.020644, 0.020777, 0.020910, 0.021045,
  0.021179, 0.021315, 0.021451, 0.021588,
  0.021726, 0.021864, 0.022003, 0.022143,
  0.022283, 0.022424, 0.022566, 0.022708,
  0.022851, 0.022995, 0.023139, 0.023284,
  0.023430, 0.023577, 0.023724, 0.023872,
  0.024020, 0.024170, 0.024320, 0.024471,
  0.024622, 0.024774, 0.024927, 0.025081,
  0.025235, 0.025391, 0.025546, 0.025703,
  0.025860, 0.026018, 0.026177, 0.026337,
  0.026497, 0.026658, 0.026820, 0.026982,
  0.027146, 0.027310, 0.027474, 0.027640,
  0.027806, 0.027973, 0.028141, 0.028310,
  0.028479, 0.028649, 0.028820, 0.028992,
  0.029164, 0.029338, 0.029512, 0.029687,
  0.029862, 0.030039, 0.030216, 0.030394,
  0.030573, 0.030752, 0.030933, 0.031114,
  0.031296, 0.031479, 0.031662, 0.031847,
  0.032032, 0.032218, 0.032405, 0.032593,
  0.032782, 0.032971, 0.033161, 0.033352,
  0.033544, 0.033737, 0.033930, 0.034125,
  0.034320, 0.034516, 0.034713, 0.034911,
  0.035110, 0.035309, 0.035510, 0.035711,
  0.035913, 0.036116, 0.036320, 0.036524,
  0.036730, 0.036936, 0.037144, 0.037352,
  0.037561, 0.037771, 0.037982, 0.038194,
  0.038406, 0.038620, 0.038834, 0.039049,
  0.039266, 0.039483, 0.039701, 0.039920,
  0.040140, 0.040360, 0.040582, 0.040805,
  0.041028, 0.041252, 0.041478, 0.041704,
  0.041931, 0.042159, 0.042388, 0.042618,
  0.042849, 0.043081, 0.043314, 0.043548,
  0.043782, 0.044018, 0.044255, 0.044492,
  0.044731, 0.044970, 0.045211, 0.045452,
  0.045694, 0.045938, 0.046182, 0.046427,
  0.046673, 0.046921, 0.047169, 0.047418,
  0.047668, 0.047919, 0.048171, 0.048424,
  0.048678, 0.048933, 0.049189, 0.049447,
  0.049705, 0.049964, 0.050224, 0.050485,
  0.050747, 0.051010, 0.051274, 0.051539,
  0.051805, 0.052073, 0.052341, 0.052610,
  0.052880, 0.053152, 0.053424, 0.053697,
  0.053972, 0.054247, 0.054523, 0.054801,
  0.055079, 0.055359, 0.055640, 0.055921,
  0.056204, 0.056488, 0.056773, 0.057059,
  0.057346, 0.057634, 0.057923, 0.058213,
  0.058504, 0.058796, 0.059090, 0.059384,
  0.059680, 0.059976, 0.060274, 0.060573,
  0.060873, 0.061174, 0.061476, 0.061779,
  0.062083, 0.062389, 0.062695, 0.063003,
  0.063311, 0.063621, 0.063932, 0.064244,
  0.064557, 0.064871, 0.065187, 0.065503,
  0.065821, 0.066139, 0.066459, 0.066780,
  0.067102, 0.067426, 0.067750, 0.068075,
  0.068402, 0.068730, 0.069059, 0.069389,
  0.069720, 0.070052, 0.070386, 0.070721,
  0.071056, 0.071393, 0.071732, 0.072071,
  0.072411, 0.072753, 0.073096, 0.073440,
  0.073785, 0.074131, 0.074479, 0.074827,
  0.075177, 0.075528, 0.075880, 0.076234,
  0.076588, 0.076944, 0.077301, 0.077659,
  0.078019, 0.078379, 0.078741, 0.079104,
  0.079468, 0.079833, 0.080200, 0.080568,
  0.080937, 0.081307, 0.081678, 0.082051,
  0.082425, 0.082800, 0.083176, 0.083553,
  0.083932, 0.084312, 0.084693, 0.085076,
  0.085459, 0.085844, 0.086230, 0.086618,
  0.087006, 0.087396, 0.087787, 0.088179,
  0.088573, 0.088968, 0.089364, 0.089761,
  0.090160, 0.090560, 0.090961, 0.091363,
  0.091767, 0.092172, 0.092578, 0.092985,
  0.093394, 0.093804, 0.094215, 0.094627,
  0.095041, 0.095456, 0.095872, 0.096290,
  0.096709, 0.097129, 0.097550, 0.097973,
  0.098397, 0.098823, 0.099249, 0.099677,
  0.100106, 0.100537, 0.100968, 0.101401,
  0.101836, 0.102271, 0.102708, 0.103147,
  0.103586, 0.104027, 0.104469, 0.104913,
  0.105358, 0.105804, 0.106251, 0.106700,
  0.107150, 0.107602, 0.108054, 0.108508,
  0.108964, 0.109420, 0.109878, 0.110338,
  0.110799, 0.111261, 0.111724, 0.112189,
  0.112655, 0.113122, 0.113591, 0.114061,
  0.114532, 0.115005, 0.115479, 0.115954,
  0.116431, 0.116909, 0.117389, 0.117869,
  0.118352, 0.118835, 0.119320, 0.119806,
  0.120294, 0.120783, 0.121273, 0.121764,
  0.122257, 0.122752, 0.123248, 0.123745,
  0.124243, 0.124743, 0.125244, 0.125747,
  0.126251, 0.126756, 0.127263, 0.127771,
  0.128280, 0.128791, 0.129303, 0.129817,
  0.130332, 0.130848, 0.131366, 0.131885,
  0.132405, 0.132927, 0.133450, 0.133975,
  0.134501, 0.135028, 0.135557, 0.136087,
  0.136619, 0.137152, 0.137686, 0.138222,
  0.138759, 0.139297, 0.139837, 0.140379,
  0.140921, 0.141465, 0.142011, 0.142558,
  0.143106, 0.143656, 0.144207, 0.144760,
  0.145313, 0.145869, 0.146425, 0.146984,
  0.147543, 0.148104, 0.148666, 0.149230,
  0.149795, 0.150362, 0.150930, 0.151499,
  0.152070, 0.152643, 0.153216, 0.153791,
  0.154368, 0.154946, 0.155525, 0.156106,
  0.156688, 0.157271, 0.157856, 0.158443,
  0.159031, 0.159620, 0.160210, 0.160803,
  0.161396, 0.161991, 0.162587, 0.163185,
  0.163784, 0.164385, 0.164987, 0.165590,
  0.166195, 0.166802, 0.167409, 0.168018,
  0.168629, 0.169241, 0.169854, 0.170469,
  0.171086, 0.171703, 0.172322, 0.172943,
  0.173565, 0.174188, 0.174813, 0.175440,
  0.176067, 0.176696, 0.177327, 0.177959,
  0.178592, 0.179227, 0.179863, 0.180501,
  0.181140, 0.181781, 0.182423, 0.183066,
  0.183711, 0.184357, 0.185005, 0.185654,
  0.186305, 0.186957, 0.187610, 0.188265,
  0.188921, 0.189579, 0.190238, 0.190899,
  0.191561, 0.192224, 0.192889, 0.193555,
  0.194223, 0.194892, 0.195562, 0.196234,
  0.196908, 0.197583, 0.198259, 0.198937,
  0.199616, 0.200296, 0.200978, 0.201662,
  0.202346, 0.203033, 0.203720, 0.204409,
  0.205100, 0.205792, 0.206485, 0.207180,
  0.207876, 0.208574, 0.209273, 0.209973,
  0.210675, 0.211378, 0.212083, 0.212789,
  0.213496, 0.214205, 0.214916, 0.215627,
  0.216341, 0.217055, 0.217771, 0.218488,
  0.219207, 0.219928, 0.220649, 0.221372,
  0.222097, 0.222823, 0.223550, 0.224278,
  0.225009, 0.225740, 0.226473, 0.227207,
  0.227943, 0.228680, 0.229418, 0.230158,
  0.230900, 0.231642, 0.232386, 0.233132,
  0.233879, 0.234627, 0.235377, 0.236128,
  0.236880, 0.237634, 0.238389, 0.239146,
  0.239904, 0.240663, 0.241424, 0.242186,
  0.242949, 0.243714, 0.244480, 0.245248,
  0.246017, 0.246788, 0.247559, 0.248332,
  0.249107, 0.249883, 0.250660, 0.251439,
  0.252219, 0.253000, 0.253783, 0.254567,
  0.255352, 0.256139, 0.256927, 0.257717,
  0.258507, 0.259300, 0.260093, 0.260888,
  0.261684, 0.262482, 0.263281, 0.264081,
  0.264883, 0.265686, 0.266490, 0.267296,
  0.268103, 0.268911, 0.269721, 0.270532,
  0.271344, 0.272158, 0.272973, 0.273789,
  0.274606, 0.275425, 0.276246, 0.277067,
  0.277890, 0.278714, 0.279540, 0.280367,
  0.281195, 0.282024, 0.282855, 0.283687,
  0.284520, 0.285355, 0.286191, 0.287028,
  0.287866, 0.288706, 0.289547, 0.290390,
  0.291233, 0.292078, 0.292924, 0.293772,
  0.294621, 0.295471, 0.296322, 0.297175,
  0.298028, 0.298883, 0.299740, 0.300597,
  0.301456, 0.302316, 0.303178, 0.304040,
  0.304904, 0.305769, 0.306636, 0.307503,
  0.308372, 0.309242, 0.310114, 0.310986,
  0.311860, 0.312735, 0.313611, 0.314489,
  0.315367, 0.316247, 0.317128, 0.318011,
  0.318894, 0.319779, 0.320665, 0.321552,
  0.322440, 0.323330, 0.324221, 0.325113,
  0.326006, 0.326900, 0.327795, 0.328692,
  0.329590, 0.330489, 0.331389, 0.332290,
  0.333193, 0.334096, 0.335001, 0.335907,
  0.336814, 0.337723, 0.338632, 0.339543,
  0.340454, 0.341367, 0.342281, 0.343196,
  0.344113, 0.345030, 0.345948, 0.346868,
  0.347789, 0.348711, 0.349634, 0.350558,
  0.351483, 0.352409, 0.353337, 0.354265,
  0.355195, 0.356125, 0.357057, 0.357990,
  0.358924, 0.359859, 0.360795, 0.361732,
  0.362670, 0.363609, 0.364550, 0.365491,
  0.366433, 0.367377, 0.368321, 0.369267,
  0.370214, 0.371161, 0.372110, 0.373060,
  0.374010, 0.374962, 0.375915, 0.376869,
  0.377823, 0.378779, 0.379736, 0.380694,
  0.381652, 0.382612, 0.383573, 0.384535,
  0.385498, 0.386461, 0.387426, 0.388392,
  0.389358, 0.390326, 0.391294, 0.392264,
  0.393234, 0.394206, 0.395178, 0.396151,
  0.397126, 0.398101, 0.399077, 0.400054,
  0.401032, 0.402011, 0.402991, 0.403971,
  0.404953, 0.405935, 0.406919, 0.407903,
  0.408888, 0.409874, 0.410861, 0.411849,
  0.412837, 0.413827, 0.414817, 0.415809,
  0.416801, 0.417794, 0.418787, 0.419782,
  0.420778, 0.421774, 0.422771, 0.423769,
  0.424768, 0.425768, 0.426768, 0.427769,
  0.428771, 0.429774, 0.430778, 0.431782,
  0.432787, 0.433793, 0.434800, 0.435808,
  0.436816, 0.437825, 0.438835, 0.439846,
  0.440857, 0.441869, 0.442882, 0.443896,
  0.444910, 0.445925, 0.446941, 0.447957,
  0.448974, 0.449992, 0.451011, 0.452030,
  0.453050, 0.454071, 0.455092, 0.456114,
  0.457137, 0.458161, 0.459185, 0.460209,
  0.461235, 0.462261, 0.463287, 0.464315,
  0.465343, 0.466371, 0.467401, 0.468430,
  0.469461, 0.470492, 0.471524, 0.472556,
  0.473589, 0.474622, 0.475657, 0.476691,
  0.477727, 0.478762, 0.479799, 0.480836,
  0.481873, 0.482911, 0.483950, 0.484989,
  0.486029, 0.487069, 0.488110, 0.489151,
  0.490193, 0.491235, 0.492278, 0.493321,
  0.494365, 0.495409, 0.496454, 0.497500,
  0.498545, 0.499592, 0.500638, 0.501685,
  0.502733, 0.503781, 0.504830, 0.505879,
  0.506928, 0.507978, 0.509028, 0.510079,
  0.511130, 0.512181, 0.513233, 0.514285,
  0.515338, 0.516391, 0.517444, 0.518498,
  0.519552, 0.520607, 0.521662, 0.522717,
  0.523772, 0.524828, 0.525885, 0.526941,
  0.527998, 0.529055, 0.530113, 0.531171,
  0.532229, 0.533287, 0.534346, 0.535405,
  0.536464, 0.537524, 0.538584, 0.539644,
  0.540704, 0.541765, 0.542826, 0.543887,
  0.544948, 0.546009, 0.547071, 0.548133,
  0.549195, 0.550258, 0.551320, 0.552383,
  0.553446, 0.554509, 0.555572, 0.556636,
  0.557700, 0.558763, 0.559827, 0.560892,
  0.561956, 0.563020, 0.564085, 0.565149,
  0.566214, 0.567279, 0.568344, 0.569409,
  0.570474, 0.571539, 0.572604, 0.573670,
  0.574735, 0.575801, 0.576866, 0.577932,
  0.578998, 0.580063, 0.581129, 0.582195,
  0.583260, 0.584326, 0.585392, 0.586458,
  0.587524, 0.588589, 0.589655, 0.590721,
  0.591787, 0.592852, 0.593918, 0.594983,
  0.596049, 0.597114, 0.598180, 0.599245,
  0.600310, 0.601375, 0.602440, 0.603505,
  0.604570, 0.605635, 0.606700, 0.607764,
  0.608828, 0.609893, 0.610957, 0.612021,
  0.613084, 0.614148, 0.615211, 0.616275,
  0.617338, 0.618401, 0.619463, 0.620526,
  0.621588, 0.622650, 0.623712, 0.624774,
  0.625835, 0.626896, 0.627957, 0.629018,
  0.630078, 0.631139, 0.632199, 0.633258,
  0.634317, 0.635376, 0.636435, 0.637494,
  0.638552, 0.639610, 0.640667, 0.641724,
  0.642781, 0.643838, 0.644894, 0.645949,
  0.647005, 0.648060, 0.649115, 0.650169,
  0.651223, 0.652276, 0.653329, 0.654382,
  0.655434, 0.656486, 0.657538, 0.658589,
  0.659639, 0.660689, 0.661739, 0.662788,
  0.663837, 0.664885, 0.665933, 0.666980,
  0.668027, 0.669074, 0.670119, 0.671165,
  0.672209, 0.673254, 0.674297, 0.675340,
  0.676383, 0.677425, 0.678467, 0.679508,
  0.680548, 0.681588, 0.682627, 0.683666,
  0.684704, 0.685741, 0.686778, 0.687814,
  0.688850, 0.689885, 0.690919, 0.691953,
  0.692986, 0.694018, 0.695050, 0.696081,
  0.697111, 0.698141, 0.699169, 0.700198,
  0.701225, 0.702252, 0.703278, 0.704303,
  0.705328, 0.706352, 0.707375, 0.708398,
  0.709419, 0.710440, 0.711460, 0.712480,
  0.713498, 0.714516, 0.715533, 0.716549,
  0.717564, 0.718579, 0.719593, 0.720605,
  0.721617, 0.722628, 0.723639, 0.724648,
  0.725657, 0.726664, 0.727671, 0.728677,
  0.729682, 0.730686, 0.731690, 0.732692,
  0.733693, 0.734694, 0.735693, 0.736692,
  0.737690, 0.738686, 0.739682, 0.740677,
  0.741671, 0.742663, 0.743655, 0.744646,
  0.745636, 0.746625, 0.747612, 0.748599,
  0.749585, 0.750570, 0.751554, 0.752536,
  0.753518, 0.754498, 0.755478, 0.756456,
  0.757433, 0.758410, 0.759385, 0.760359,
  0.761332, 0.762303, 0.763274, 0.764243,
  0.765212, 0.766179, 0.767145, 0.768110,
  0.769074, 0.770037, 0.770998, 0.771958,
  0.772917, 0.773875, 0.774832, 0.775787,
  0.776742, 0.777695, 0.778647, 0.779597,
  0.780546, 0.781495, 0.782441, 0.783387,
  0.784331, 0.785274, 0.786216, 0.787156,
  0.788096, 0.789033, 0.789970, 0.790905,
  0.791839, 0.792772, 0.793703, 0.794633,
  0.795561, 0.796489, 0.797415, 0.798339,
  0.799262, 0.800184, 0.801104, 0.802023,
  0.802941, 0.803857, 0.804772, 0.805685,
  0.806597, 0.807507, 0.808417, 0.809324,
  0.810230, 0.811135, 0.812038, 0.812940,
  0.813840, 0.814739, 0.815636, 0.816532,
  0.817426, 0.818319, 0.819210, 0.820100,
  0.820988, 0.821875, 0.822760, 0.823644,
  0.824526, 0.825407, 0.826285, 0.827163,
  0.828039, 0.828913, 0.829785, 0.830656,
  0.831526, 0.832394, 0.833260, 0.834124,
  0.834987, 0.835849, 0.836708, 0.837566,
  0.838423, 0.839277, 0.840130, 0.840982,
  0.841831, 0.842680, 0.843526, 0.844370,
  0.845213, 0.846055, 0.846894, 0.847732,
  0.848568, 0.849402, 0.850235, 0.851066,
  0.851895, 0.852722, 0.853547, 0.854371,
  0.855193, 0.856014, 0.856832, 0.857649,
  0.858463, 0.859276, 0.860088, 0.860897,
  0.861705, 0.862510, 0.863314, 0.864116,
  0.864917, 0.865715, 0.866512, 0.867306,
  0.868099, 0.868890, 0.869679, 0.870466,
  0.871251, 0.872034, 0.872816, 0.873596,
  0.874373, 0.875149, 0.875923, 0.876695,
  0.877464, 0.878232, 0.878998, 0.879762,
  0.880524, 0.881284, 0.882043, 0.882799,
  0.883553, 0.884305, 0.885055, 0.885803,
  0.886549, 0.887294, 0.888036, 0.888776,
  0.889514, 0.890250, 0.890984, 0.891716,
  0.892446, 0.893174, 0.893899, 0.894623,
  0.895345, 0.896064, 0.896782, 0.897497,
  0.898210, 0.898921, 0.899630, 0.900337,
  0.901042, 0.901745, 0.902445, 0.903144,
  0.903840, 0.904534, 0.905226, 0.905916,
  0.906604, 0.907290, 0.907973, 0.908654,
  0.909333, 0.910010, 0.910685, 0.911357,
  0.912027, 0.912695, 0.913361, 0.914025,
  0.914686, 0.915345, 0.916002, 0.916657,
  0.917309, 0.917960, 0.918607, 0.919253,
  0.919897, 0.920538, 0.921177, 0.921813,
  0.922448, 0.923080, 0.923710, 0.924337,
  0.924962, 0.925585, 0.926206, 0.926824,
  0.927440, 0.928053, 0.928665, 0.929274,
  0.929880, 0.930485, 0.931087, 0.931686,
  0.932283, 0.932878, 0.933471, 0.934061,
  0.934648, 0.935234, 0.935817, 0.936398,
  0.936976, 0.937552, 0.938125, 0.938696,
  0.939265, 0.939831, 0.940395, 0.940956,
  0.941515, 0.942071, 0.942625, 0.943177,
  0.943726, 0.944273, 0.944817, 0.945359,
  0.945898, 0.946435, 0.946970, 0.947502,
  0.948031, 0.948558, 0.949082, 0.949604,
  0.950124, 0.950641, 0.951155, 0.951667,
  0.952177, 0.952684, 0.953188, 0.953690,
  0.954190, 0.954687, 0.955181, 0.955673,
  0.956162, 0.956649, 0.957133, 0.957615,
  0.958094, 0.958570, 0.959044, 0.959516,
  0.959984, 0.960451, 0.960914, 0.961375,
  0.961834, 0.962290, 0.962743, 0.963194,
  0.963642, 0.964087, 0.964530, 0.964971,
  0.965408, 0.965843, 0.966276, 0.966706,
  0.967133, 0.967557, 0.967979, 0.968399,
  0.968815, 0.969230, 0.969641, 0.970050,
  0.970456, 0.970859, 0.971260, 0.971658,
  0.972053, 0.972446, 0.972836, 0.973223,
  0.973608, 0.973990, 0.974370, 0.974746,
  0.975120, 0.975492, 0.975860, 0.976226,
  0.976589, 0.976950, 0.977308, 0.977663,
  0.978015, 0.978365, 0.978712, 0.979056,
  0.979397, 0.979736, 0.980072, 0.980406,
  0.980736, 0.981064, 0.981389, 0.981711,
  0.982031, 0.982348, 0.982662, 0.982973,
  0.983282, 0.983588, 0.983891, 0.984191,
  0.984489, 0.984783, 0.985076, 0.985365,
  0.985651, 0.985935, 0.986216, 0.986494,
  0.986769, 0.987042, 0.987312, 0.987579,
  0.987843, 0.988104, 0.988363, 0.988619,
  0.988872, 0.989122, 0.989370, 0.989614,
  0.989856, 0.990095, 0.990331, 0.990565,
  0.990795, 0.991023, 0.991248, 0.991470,
  0.991689, 0.991906, 0.992119, 0.992330,
  0.992538, 0.992743, 0.992946, 0.993145,
  0.993342, 0.993536, 0.993726, 0.993915,
  0.994100, 0.994283, 0.994462, 0.994639,
  0.994813, 0.994984, 0.995152, 0.995318,
  0.995480, 0.995640, 0.995797, 0.995951,
  0.996102, 0.996250, 0.996395, 0.996538,
  0.996678, 0.996814, 0.996948, 0.997079,
  0.997208, 0.997333, 0.997455, 0.997575,
  0.997692, 0.997806, 0.997917, 0.998025,
  0.998130, 0.998232, 0.998332, 0.998429,
  0.998522, 0.998613, 0.998701, 0.998786,
  0.998869, 0.998948, 0.999024, 0.999098,
  0.999169, 0.999236, 0.999302, 0.999363,
  0.999423, 0.999479, 0.999532, 0.999583,
  0.999631, 0.999675, 0.999717, 0.999756,
  0.999792, 0.999825, 0.999856, 0.999883,
  0.999908, 0.999929, 0.999948, 0.999964,
  0.999977, 0.999987, 0.999994, 0.999999,
  1.000000, 0.999999, 0.999994, 0.999987,
  0.999977, 0.999964, 0.999948, 0.999929,
  0.999907, 0.999883, 0.999856, 0.999825,
  0.999792, 0.999756, 0.999717, 0.999675,
  0.999630, 0.999582, 0.999532, 0.999478,
  0.999422, 0.999363, 0.999301, 0.999236,
  0.999168, 0.999097, 0.999023, 0.998947,
  0.998868, 0.998785, 0.998700, 0.998612,
  0.998521, 0.998427, 0.998331, 0.998231,
  0.998129, 0.998024, 0.997916, 0.997804,
  0.997690, 0.997574, 0.997454, 0.997332,
  0.997206, 0.997078, 0.996947, 0.996813,
  0.996676, 0.996536, 0.996394, 0.996248,
  0.996100, 0.995949, 0.995795, 0.995638,
  0.995478, 0.995316, 0.995150, 0.994982,
  0.994811, 0.994637, 0.994460, 0.994281,
  0.994098, 0.993913, 0.993725, 0.993533,
  0.993340, 0.993143, 0.992943, 0.992741,
  0.992536, 0.992328, 0.992117, 0.991903,
  0.991687, 0.991468, 0.991245, 0.991020,
  0.990793, 0.990562, 0.990329, 0.990092,
  0.989853, 0.989611, 0.989367, 0.989119,
  0.988869, 0.988616, 0.988360, 0.988102,
  0.987840, 0.987576, 0.987309, 0.987039,
  0.986766, 0.986491, 0.986213, 0.985932,
  0.985648, 0.985362, 0.985072, 0.984780,
  0.984486, 0.984188, 0.983887, 0.983584,
  0.983279, 0.982970, 0.982658, 0.982344,
  0.982027, 0.981708, 0.981385, 0.981060,
  0.980733, 0.980402, 0.980069, 0.979732,
  0.979394, 0.979052, 0.978708, 0.978361,
  0.978011, 0.977659, 0.977304, 0.976946,
  0.976585, 0.976222, 0.975856, 0.975488,
  0.975116, 0.974742, 0.974365, 0.973986,
  0.973604, 0.973219, 0.972832, 0.972442,
  0.972049, 0.971653, 0.971255, 0.970855,
  0.970451, 0.970045, 0.969636, 0.969225,
  0.968811, 0.968394, 0.967975, 0.967553,
  0.967128, 0.966701, 0.966271, 0.965839,
  0.965404, 0.964966, 0.964525, 0.964083,
  0.963637, 0.963189, 0.962738, 0.962285,
  0.961829, 0.961370, 0.960909, 0.960446,
  0.959979, 0.959510, 0.959039, 0.958565,
  0.958088, 0.957609, 0.957128, 0.956644,
  0.956157, 0.955667, 0.955176, 0.954681,
  0.954184, 0.953685, 0.953183, 0.952679,
  0.952172, 0.951662, 0.951150, 0.950635,
  0.950118, 0.949599, 0.949077, 0.948552,
  0.948025, 0.947496, 0.946964, 0.946429,
  0.945892, 0.945353, 0.944811, 0.944267,
  0.943720, 0.943171, 0.942619, 0.942065,
  0.941509, 0.940950, 0.940388, 0.939825,
  0.939258, 0.938690, 0.938119, 0.937545,
  0.936969, 0.936391, 0.935811, 0.935228,
  0.934642, 0.934054, 0.933464, 0.932872,
  0.932277, 0.931680, 0.931080, 0.930478,
  0.929874, 0.929267, 0.928658, 0.928047,
  0.927433, 0.926817, 0.926199, 0.925578,
  0.924955, 0.924330, 0.923703, 0.923073,
  0.922441, 0.921807, 0.921170, 0.920531,
  0.919890, 0.919246, 0.918600, 0.917953,
  0.917302, 0.916650, 0.915995, 0.915338,
  0.914679, 0.914018, 0.913354, 0.912688,
  0.912020, 0.911350, 0.910677, 0.910003,
  0.909326, 0.908647, 0.907966, 0.907282,
  0.906597, 0.905909, 0.905219, 0.904527,
  0.903833, 0.903136, 0.902438, 0.901737,
  0.901035, 0.900330, 0.899623, 0.898914,
  0.898202, 0.897489, 0.896774, 0.896056,
  0.895337, 0.894615, 0.893891, 0.893166,
  0.892438, 0.891708, 0.890976, 0.890242,
  0.889506, 0.888768, 0.888028, 0.887285,
  0.886541, 0.885795, 0.885047, 0.884297,
  0.883545, 0.882791, 0.882034, 0.881276,
  0.880516, 0.879754, 0.878990, 0.878224,
  0.877456, 0.876686, 0.875914, 0.875140,
  0.874365, 0.873587, 0.872808, 0.872026,
  0.871243, 0.870458, 0.869671, 0.868881,
  0.868090, 0.867298, 0.866503, 0.865706,
  0.864908, 0.864108, 0.863306, 0.862502,
  0.861696, 0.860888, 0.860079, 0.859268,
  0.858455, 0.857640, 0.856823, 0.856004,
  0.855184, 0.854362, 0.853538, 0.852713,
  0.851886, 0.851057, 0.850226, 0.849393,
  0.848559, 0.847723, 0.846885, 0.846045,
  0.845204, 0.844361, 0.843517, 0.842670,
  0.841822, 0.840972, 0.840121, 0.839268,
  0.838413, 0.837557, 0.836699, 0.835839,
  0.834978, 0.834115, 0.833250, 0.832384,
  0.831517, 0.830647, 0.829776, 0.828903,
  0.828029, 0.827153, 0.826276, 0.825397,
  0.824516, 0.823634, 0.822751, 0.821865,
  0.820979, 0.820090, 0.819201, 0.818309,
  0.817417, 0.816522, 0.815627, 0.814729,
  0.813830, 0.812930, 0.812028, 0.811125,
  0.810220, 0.809314, 0.808407, 0.807498,
  0.806587, 0.805675, 0.804762, 0.803847,
  0.802931, 0.802013, 0.801094, 0.800174,
  0.799252, 0.798329, 0.797405, 0.796479,
  0.795551, 0.794623, 0.793693, 0.792762,
  0.791829, 0.790895, 0.789960, 0.789023,
  0.788085, 0.787146, 0.786206, 0.785264,
  0.784321, 0.783377, 0.782431, 0.781484,
  0.780536, 0.779587, 0.778636, 0.777684,
  0.776731, 0.775777, 0.774822, 0.773865,
  0.772907, 0.771948, 0.770988, 0.770026,
  0.769064, 0.768100, 0.767135, 0.766169,
  0.765201, 0.764233, 0.763263, 0.762293,
  0.761321, 0.760348, 0.759374, 0.758399,
  0.757423, 0.756445, 0.755467, 0.754488,
  0.753507, 0.752526, 0.751543, 0.750559,
  0.749574, 0.748589, 0.747602, 0.746614,
  0.745625, 0.744635, 0.743645, 0.742653,
  0.741660, 0.740666, 0.739671, 0.738675,
  0.737679, 0.736681, 0.735683, 0.734683,
  0.733683, 0.732681, 0.731679, 0.730676,
  0.729671, 0.728666, 0.727660, 0.726654,
  0.725646, 0.724637, 0.723628, 0.722617,
  0.721606, 0.720594, 0.719581, 0.718568,
  0.717553, 0.716538, 0.715522, 0.714505,
  0.713487, 0.712468, 0.711449, 0.710429,
  0.709408, 0.708386, 0.707364, 0.706341,
  0.705317, 0.704292, 0.703267, 0.702241,
  0.701214, 0.700186, 0.699158, 0.698129,
  0.697100, 0.696069, 0.695038, 0.694007,
  0.692974, 0.691941, 0.690908, 0.689873,
  0.688838, 0.687803, 0.686767, 0.685730,
  0.684693, 0.683654, 0.682616, 0.681577,
  0.680537, 0.679496, 0.678455, 0.677414,
  0.676372, 0.675329, 0.674286, 0.673242,
  0.672198, 0.671153, 0.670108, 0.669062,
  0.668016, 0.666969, 0.665922, 0.664874,
  0.663826, 0.662777, 0.661728, 0.660678,
  0.659628, 0.658577, 0.657526, 0.656475,
  0.655423, 0.654371, 0.653318, 0.652265,
  0.651211, 0.650157, 0.649103, 0.648048,
  0.646993, 0.645938, 0.644882, 0.643826,
  0.642770, 0.641713, 0.640656, 0.639598,
  0.638540, 0.637482, 0.636424, 0.635365,
  0.634306, 0.633247, 0.632187, 0.631127,
  0.630067, 0.629007, 0.627946, 0.626885,
  0.625824, 0.624762, 0.623701, 0.622639,
  0.621577, 0.620514, 0.619452, 0.618389,
  0.617326, 0.616263, 0.615200, 0.614137,
  0.613073, 0.612009, 0.610945, 0.609881,
  0.608817, 0.607753, 0.606688, 0.605623,
  0.604559, 0.603494, 0.602429, 0.601364,
  0.600299, 0.599233, 0.598168, 0.597103,
  0.596037, 0.594972, 0.593906, 0.592841,
  0.591775, 0.590709, 0.589644, 0.588578,
  0.587512, 0.586446, 0.585380, 0.584315,
  0.583249, 0.582183, 0.581117, 0.580052,
  0.578986, 0.577920, 0.576855, 0.575789,
  0.574724, 0.573658, 0.572593, 0.571528,
  0.570462, 0.569397, 0.568332, 0.567267,
  0.566202, 0.565138, 0.564073, 0.563009,
  0.561944, 0.560880, 0.559816, 0.558752,
  0.557688, 0.556624, 0.555561, 0.554498,
  0.553434, 0.552372, 0.551309, 0.550246,
  0.549184, 0.548122, 0.547060, 0.545998,
  0.544936, 0.543875, 0.542814, 0.541753,
  0.540693, 0.539632, 0.538572, 0.537512,
  0.536453, 0.535393, 0.534334, 0.533276,
  0.532217, 0.531159, 0.530101, 0.529044,
  0.527987, 0.526930, 0.525873, 0.524817,
  0.523761, 0.522705, 0.521650, 0.520595,
  0.519541, 0.518487, 0.517433, 0.516379,
  0.515326, 0.514274, 0.513222, 0.512170,
  0.511118, 0.510067, 0.509017, 0.507966,
  0.506916, 0.505867, 0.504818, 0.503770,
  0.502722, 0.501674, 0.500627, 0.499580,
  0.498534, 0.497488, 0.496443, 0.495398,
  0.494354, 0.493310, 0.492267, 0.491224,
  0.490182, 0.489140, 0.488098, 0.487058,
  0.486018, 0.484978, 0.483939, 0.482900,
  0.481862, 0.480824, 0.479787, 0.478751,
  0.477715, 0.476680, 0.475645, 0.474611,
  0.473578, 0.472545, 0.471513, 0.470481,
  0.469450, 0.468419, 0.467389, 0.466360,
  0.465332, 0.464304, 0.463276, 0.462250,
  0.461223, 0.460198, 0.459173, 0.458149,
  0.457126, 0.456103, 0.455081, 0.454060,
  0.453039, 0.452019, 0.451000, 0.449981,
  0.448963, 0.447946, 0.446930, 0.445914,
  0.444899, 0.443885, 0.442871, 0.441858,
  0.440846, 0.439835, 0.438824, 0.437814,
  0.436805, 0.435797, 0.434789, 0.433782,
  0.432776, 0.431771, 0.430767, 0.429763,
  0.428760, 0.427758, 0.426757, 0.425757,
  0.424757, 0.423758, 0.422760, 0.421763,
  0.420767, 0.419771, 0.418777, 0.417783,
  0.416790, 0.415798, 0.414807, 0.413816,
  0.412827, 0.411838, 0.410850, 0.409863,
  0.408877, 0.407892, 0.406908, 0.405924,
  0.404942, 0.403961, 0.402980, 0.402000,
  0.401021, 0.400043, 0.399066, 0.398090,
  0.397115, 0.396141, 0.395168, 0.394195,
  0.393224, 0.392253, 0.391284, 0.390315,
  0.389348, 0.388381, 0.387415, 0.386451,
  0.385487, 0.384524, 0.383563, 0.382602,
  0.381642, 0.380683, 0.379725, 0.378769,
  0.377813, 0.376858, 0.375904, 0.374952,
  0.374000, 0.373049, 0.372100, 0.371151,
  0.370203, 0.369257, 0.368311, 0.367367,
  0.366423, 0.365481, 0.364539, 0.363599,
  0.362660, 0.361722, 0.360785, 0.359848,
  0.358913, 0.357980, 0.357047, 0.356115,
  0.355184, 0.354255, 0.353326, 0.352399,
  0.351473, 0.350548, 0.349624, 0.348701,
  0.347779, 0.346858, 0.345938, 0.345020,
  0.344103, 0.343186, 0.342271, 0.341357,
  0.340444, 0.339533, 0.338622, 0.337713,
  0.336804, 0.335897, 0.334991, 0.334087,
  0.333183, 0.332280, 0.331379, 0.330479,
  0.329580, 0.328682, 0.327786, 0.326890,
  0.325996, 0.325103, 0.324211, 0.323320,
  0.322431, 0.321542, 0.320655, 0.319769,
  0.318885, 0.318001, 0.317119, 0.316238,
  0.315358, 0.314479, 0.313602, 0.312726,
  0.311851, 0.310977, 0.310104, 0.309233,
  0.308363, 0.307494, 0.306626, 0.305760,
  0.304895, 0.304031, 0.303168, 0.302307,
  0.301447, 0.300588, 0.299730, 0.298874,
  0.298019, 0.297165, 0.296313, 0.295461,
  0.294611, 0.293763, 0.292915, 0.292069,
  0.291224, 0.290380, 0.289538, 0.288697,
  0.287857, 0.287019, 0.286182, 0.285346,
  0.284511, 0.283678, 0.282846, 0.282015,
  0.281186, 0.280358, 0.279531, 0.278705,
  0.277881, 0.277058, 0.276237, 0.275416,
  0.274598, 0.273780, 0.272964, 0.272149,
  0.271335, 0.270523, 0.269712, 0.268902,
  0.268094, 0.267287, 0.266481, 0.265677,
  0.264874, 0.264072, 0.263272, 0.262473,
  0.261676, 0.260879, 0.260085, 0.259291,
  0.258499, 0.257708, 0.256918, 0.256130,
  0.255344, 0.254558, 0.253774, 0.252991,
  0.252210, 0.251430, 0.250652, 0.249874,
  0.249098, 0.248324, 0.247551, 0.246779,
  0.246009, 0.245240, 0.244472, 0.243706,
  0.242941, 0.242178, 0.241415, 0.240655,
  0.239895, 0.239137, 0.238381, 0.237626,
  0.236872, 0.236119, 0.235368, 0.234619,
  0.233871, 0.233124, 0.232378, 0.231634,
  0.230892, 0.230150, 0.229410, 0.228672,
  0.227935, 0.227199, 0.226465, 0.225732,
  0.225001, 0.224271, 0.223542, 0.222815,
  0.222089, 0.221364, 0.220641, 0.219920,
  0.219199, 0.218481, 0.217763, 0.217047,
  0.216333, 0.215620, 0.214908, 0.214198,
  0.213489, 0.212781, 0.212075, 0.211370,
  0.210667, 0.209965, 0.209265, 0.208566,
  0.207868, 0.207172, 0.206477, 0.205784,
  0.205092, 0.204402, 0.203713, 0.203025,
  0.202339, 0.201654, 0.200971, 0.200289,
  0.199608, 0.198929, 0.198252, 0.197575,
  0.196901, 0.196227, 0.195555, 0.194885,
  0.194216, 0.193548, 0.192882, 0.192217,
  0.191553, 0.190891, 0.190231, 0.189572,
  0.188914, 0.188258, 0.187603, 0.186950,
  0.186298, 0.185647, 0.184998, 0.184350,
  0.183704, 0.183059, 0.182416, 0.181774,
  0.181133, 0.180494, 0.179856, 0.179220,
  0.178585, 0.177952, 0.177320, 0.176690,
  0.176060, 0.175433, 0.174806, 0.174182,
  0.173558, 0.172936, 0.172316, 0.171697,
  0.171079, 0.170463, 0.169848, 0.169234,
  0.168622, 0.168012, 0.167403, 0.166795,
  0.166189, 0.165584, 0.164980, 0.164378,
  0.163778, 0.163179, 0.162581, 0.161985,
  0.161390, 0.160796, 0.160204, 0.159613,
  0.159024, 0.158436, 0.157850, 0.157265,
  0.156681, 0.156099, 0.155519, 0.154939,
  0.154361, 0.153785, 0.153210, 0.152636,
  0.152064, 0.151493, 0.150924, 0.150356,
  0.149789, 0.149224, 0.148660, 0.148098,
  0.147537, 0.146978, 0.146419, 0.145863,
  0.145307, 0.144754, 0.144201, 0.143650,
  0.143100, 0.142552, 0.142005, 0.141460,
  0.140915, 0.140373, 0.139831, 0.139291,
  0.138753, 0.138216, 0.137680, 0.137146,
  0.136613, 0.136081, 0.135551, 0.135022,
  0.134495, 0.133969, 0.133444, 0.132921,
  0.132399, 0.131879, 0.131360, 0.130842,
  0.130326, 0.129811, 0.129298, 0.128785,
  0.128275, 0.127765, 0.127257, 0.126750,
  0.126245, 0.125741, 0.125239, 0.124738,
  0.124238, 0.123739, 0.123242, 0.122746,
  0.122252, 0.121759, 0.121268, 0.120777,
  0.120288, 0.119801, 0.119315, 0.118830,
  0.118346, 0.117864, 0.117383, 0.116904,
  0.116426, 0.115949, 0.115474, 0.115000,
  0.114527, 0.114056, 0.113586, 0.113117,
  0.112650, 0.112184, 0.111719, 0.111256,
  0.110794, 0.110333, 0.109874, 0.109416,
  0.108959, 0.108503, 0.108049, 0.107597,
  0.107145, 0.106695, 0.106246, 0.105799,
  0.105353, 0.104908, 0.104465, 0.104022,
  0.103582, 0.103142, 0.102704, 0.102267,
  0.101831, 0.101397, 0.100964, 0.100532,
  0.100101, 0.099672, 0.099244, 0.098818,
  0.098393, 0.097969, 0.097546, 0.097124,
  0.096704, 0.096285, 0.095868, 0.095452,
  0.095037, 0.094623, 0.094210, 0.093799,
  0.093389, 0.092981, 0.092573, 0.092167,
  0.091762, 0.091359, 0.090956, 0.090555,
  0.090155, 0.089757, 0.089360, 0.088964,
  0.088569, 0.088175, 0.087783, 0.087392,
  0.087002, 0.086613, 0.086226, 0.085840,
  0.085455, 0.085072, 0.084689, 0.084308,
  0.083928, 0.083549, 0.083172, 0.082796,
  0.082421, 0.082047, 0.081674, 0.081303,
  0.080933, 0.080564, 0.080196, 0.079829,
  0.079464, 0.079100, 0.078737, 0.078375,
  0.078015, 0.077655, 0.077297, 0.076940,
  0.076584, 0.076230, 0.075877, 0.075524,
  0.075173, 0.074823, 0.074475, 0.074127,
  0.073781, 0.073436, 0.073092, 0.072749,
  0.072408, 0.072067, 0.071728, 0.071390,
  0.071053, 0.070717, 0.070382, 0.070049,
  0.069716, 0.069385, 0.069055, 0.068726,
  0.068398, 0.068072, 0.067746, 0.067422,
  0.067099, 0.066777, 0.066456, 0.066136,
  0.065817, 0.065500, 0.065183, 0.064868,
  0.064554, 0.064241, 0.063929, 0.063618,
  0.063308, 0.062999, 0.062692, 0.062385,
  0.062080, 0.061776, 0.061473, 0.061171,
  0.060870, 0.060570, 0.060271, 0.059973,
  0.059677, 0.059381, 0.059087, 0.058793,
  0.058501, 0.058210, 0.057920, 0.057630,
  0.057342, 0.057055, 0.056770, 0.056485,
  0.056201, 0.055918, 0.055637, 0.055356,
  0.055076, 0.054798, 0.054520, 0.054244,
  0.053968, 0.053694, 0.053421, 0.053149,
  0.052877, 0.052607, 0.052338, 0.052070,
  0.051803, 0.051536, 0.051271, 0.051007,
  0.050744, 0.050482, 0.050221, 0.049961,
  0.049702, 0.049444, 0.049187, 0.048931,
  0.048676, 0.048422, 0.048168, 0.047916,
  0.047665, 0.047415, 0.047166, 0.046918,
  0.046671, 0.046424, 0.046179, 0.045935,
  0.045692, 0.045449, 0.045208, 0.044968,
  0.044728, 0.044490, 0.044252, 0.044016,
  0.043780, 0.043545, 0.043311, 0.043079,
  0.042847, 0.042616, 0.042386, 0.042157,
  0.041929, 0.041702, 0.041475, 0.041250,
  0.041026, 0.040802, 0.040580, 0.040358,
  0.040137, 0.039917, 0.039698, 0.039480,
  0.039263, 0.039047, 0.038832, 0.038617,
  0.038404, 0.038191, 0.037980, 0.037769,
  0.037559, 0.037350, 0.037141, 0.036934,
  0.036728, 0.036522, 0.036317, 0.036114,
  0.035911, 0.035709, 0.035507, 0.035307,
  0.035107, 0.034909, 0.034711, 0.034514,
  0.034318, 0.034123, 0.033928, 0.033735,
  0.033542, 0.033350, 0.033159, 0.032969,
  0.032779, 0.032591, 0.032403, 0.032216,
  0.032030, 0.031845, 0.031660, 0.031477,
  0.031294, 0.031112, 0.030931, 0.030750,
  0.030571, 0.030392, 0.030214, 0.030037,
  0.029860, 0.029685, 0.029510, 0.029336,
  0.029163, 0.028990, 0.028818, 0.028647,
  0.028477, 0.028308, 0.028139, 0.027971,
  0.027804, 0.027638, 0.027473, 0.027308,
  0.027144, 0.026981, 0.026818, 0.026656,
  0.026495, 0.026335, 0.026175, 0.026017,
  0.025859, 0.025701, 0.025545, 0.025389,
  0.025234, 0.025079, 0.024926, 0.024773,
  0.024621, 0.024469, 0.024318, 0.024168,
  0.024019, 0.023870, 0.023722, 0.023575,
  0.023429, 0.023283, 0.023138, 0.022993,
  0.022849, 0.022706, 0.022564, 0.022422,
  0.022281, 0.022141, 0.022001, 0.021863,
  0.021724, 0.021587, 0.021450, 0.021314,
  0.021178, 0.021043, 0.020909, 0.020775,
  0.020642, 0.020510, 0.020378, 0.020247,
  0.020117, 0.019988, 0.019859, 0.019730,
  0.019602, 0.019475, 0.019349, 0.019223,
  0.019098, 0.018973, 0.018849, 0.018726,
  0.018603, 0.018481, 0.018360, 0.018239,
  0.018119, 0.017999, 0.017880, 0.017762,
  0.017644, 0.017527, 0.017411, 0.017295,
  0.017179, 0.017064, 0.016950, 0.016837,
  0.016724, 0.016611, 0.016500, 0.016388,
  0.016278, 0.016168, 0.016058, 0.015949,
  0.015841, 0.015733, 0.015626, 0.015519,
  0.015413, 0.015308, 0.015203, 0.015099,
  0.014995, 0.014891, 0.014789, 0.014687,
  0.014585, 0.014484, 0.014383, 0.014283,
  0.014184, 0.014085, 0.013987, 0.013889,
  0.013792, 0.013695, 0.013599, 0.013503,
  0.013408, 0.013313, 0.013219, 0.013125,
  0.013032, 0.012940, 0.012848, 0.012756,
  0.012665, 0.012574, 0.012484, 0.012395,
  0.012306, 0.012217, 0.012129, 0.012042,
  0.011955, 0.011868, 0.011782, 0.011696,
  0.011611, 0.011527, 0.011442, 0.011359,
  0.011276, 0.011193, 0.011111, 0.011029,
  0.010948, 0.010867, 0.010786, 0.010706,
  0.010627, 0.010548, 0.010469, 0.010391,
  0.010314, 0.010237, 0.010160, 0.010084,
  0.010008, 0.009932, 0.009858, 0.009783,
  0.009709, 0.009635, 0.009562, 0.009490,
  0.009417, 0.009345, 0.009274, 0.009203,
  0.009132, 0.009062, 0.008992, 0.008923,
  0.008854, 0.008786, 0.008718, 0.008650,
  0.008583, 0.008516, 0.008449, 0.008383,
  0.008318, 0.008252, 0.008188, 0.008123,
  0.008059, 0.007996, 0.007932, 0.007869,
  0.007807, 0.007745, 0.007683, 0.007622,
  0.007561, 0.007500, 0.007440, 0.007380,
  0.007321, 0.007262, 0.007203, 0.007145,
  0.007087, 0.007030, 0.006972, 0.006916,
  0.006859, 0.006803, 0.006747, 0.006692,
  0.006637, 0.006582, 0.006528, 0.006474,
  0.006420, 0.006367, 0.006314, 0.006261,
  0.006209, 0.006157, 0.006106, 0.006054,
  0.006003, 0.005953, 0.005903, 0.005853,
  0.005803, 0.005754, 0.005705, 0.005656,
  0.005608, 0.005560, 0.005513, 0.005465,
  0.005418, 0.005372, 0.005325, 0.005279,
  0.005234, 0.005188, 0.005143, 0.005098,
  0.005054, 0.005010, 0.004966, 0.004922,
  0.004879, 0.004836, 0.004793, 0.004751,
  0.004709, 0.004667, 0.004625, 0.004584,
  0.004543, 0.004502, 0.004462, 0.004422,
  0.004382, 0.004342, 0.004303, 0.004264,
  0.004226, 0.004187, 0.004149, 0.004111,
  0.004073, 0.004036, 0.003999, 0.003962,
  0.003926, 0.003889, 0.003853, 0.003818,
  0.003782, 0.003747, 0.003712, 0.003677,
  0.003643, 0.003608, 0.003574, 0.003541,
  0.003507, 0.003474, 0.003441, 0.003408,
  0.003376, 0.003343, 0.003311, 0.003280,
  0.003248, 0.003217, 0.003186, 0.003155,
  0.003124, 0.003094, 0.003064, 0.003034,
  0.003004, 0.002975, 0.002945, 0.002916,
  0.002887, 0.002859, 0.002831, 0.002802,
  0.002774, 0.002747, 0.002719, 0.002692,
  0.002665, 0.002638, 0.002611, 0.002585,
  0.002559, 0.002533, 0.002507, 0.002481,
  0.002456, 0.002431, 0.002406, 0.002381,
  0.002356, 0.002332, 0.002308, 0.002284,
  0.002260, 0.002236, 0.002213, 0.002189,
  0.002166, 0.002144, 0.002121, 0.002098,
  0.002076, 0.002054, 0.002032, 0.002010,
  0.001989, 0.001967, 0.001946, 0.001925,
  0.001904, 0.001883, 0.001863, 0.001842,
  0.001822, 0.001802, 0.001782, 0.001763,
  0.001743, 0.001724, 0.001705, 0.001686,
  0.001667, 0.001648, 0.001630, 0.001611,
  0.001593, 0.001575, 0.001557, 0.001539,
  0.001522, 0.001504, 0.001487, 0.001470,
  0.001453, 0.001436, 0.001419, 0.001403,
  0.001386, 0.001370, 0.001354, 0.001338,
  0.001322, 0.001307, 0.001291, 0.001276,
  0.001261, 0.001246, 0.001231, 0.001216,
  0.001201, 0.001187, 0.001172, 0.001158,
  0.001144, 0.001130, 0.001116, 0.001102,
  0.001088, 0.001075, 0.001061, 0.001048,
  0.001035, 0.001022, 0.001009, 0.000997,
  0.000984, 0.000971, 0.000959, 0.000947,
  0.000935, 0.000923, 0.000911, 0.000899,
  0.000887, 0.000876, 0.000864, 0.000853,
  0.000842, 0.000830, 0.000819, 0.000809,
  0.000798, 0.000787, 0.000776, 0.000766,
  0.000756, 0.000745, 0.000735, 0.000725,
  0.000715, 0.000705, 0.000696, 0.000686,
  0.000676, 0.000667, 0.000658, 0.000648,
  0.000639, 0.000630, 0.000621, 0.000612,
  0.000604, 0.000595, 0.000586, 0.000578,
  0.000569, 0.000561, 0.000553, 0.000545,
  0.000537, 0.000529, 0.000521, 0.000513,
  0.000505, 0.000498, 0.000490, 0.000483,
  0.000475, 0.000468, 0.000461, 0.000454,
  0.000447, 0.000440, 0.000433, 0.000426,
  0.000419, 0.000413, 0.000406, 0.000400,
  0.000393, 0.000387, 0.000381, 0.000374,
  0.000368, 0.000362, 0.000356, 0.000350,
  0.000345, 0.000339, 0.000333, 0.000327,
  0.000322, 0.000316, 0.000311, 0.000306,
  0.000300, 0.000295, 0.000290, 0.000285,
  0.000280, 0.000275, 0.000270, 0.000265,
  0.000260, 0.000256, 0.000251, 0.000246,
  0.000242, 0.000237, 0.000233, 0.000228,
  0.000224, 0.000220, 0.000216, 0.000211,
  0.000207, 0.000203, 0.000199, 0.000195,
  0.000192, 0.000188, 0.000184, 0.000180,
  0.000177, 0.000173, 0.000169, 0.000166,
  0.000162, 0.000159, 0.000156, 0.000152,
  0.000149, 0.000146, 0.000143, 0.000139,
  0.000136, 0.000133, 0.000130, 0.000127,
  0.000124, 0.000122, 0.000119, 0.000116,
  0.000113, 0.000110, 0.000108, 0.000105,
  0.000103, 0.000100, 0.000098, 0.000095,
  0.000093, 0.000090, 0.000088, 0.000086,
  0.000083, 0.000081, 0.000079, 0.000077,
  0.000075, 0.000073, 0.000071, 0.000069,
  0.000067, 0.000065, 0.000063, 0.000061,
  0.000059, 0.000057, 0.000055, 0.000054,
  0.000052, 0.000050, 0.000049, 0.000047,
  0.000045, 0.000044, 0.000042, 0.000041,
  0.000039, 0.000038, 0.000036, 0.000035,
  0.000034, 0.000032, 0.000031, 0.000030,
  0.000028, 0.000027, 0.000026, 0.000025,
  0.000024, 0.000022, 0.000021, 0.000020,
  0.000019, 0.000018, 0.000017, 0.000016,
  0.000015, 0.000014, 0.000013, 0.000012,
  0.000011, 0.000011, 0.000010, 0.000009,
  0.000008, 0.000007, 0.000007, 0.000006,
  0.000005, 0.000004, 0.000004, 0.000003,
  0.000002, 0.000002, 0.000001, 0.000001
};



float
ifft_sinc (float fTheta)
{
  int index = (int) (.5 + ifft_scale_sinc * fTheta);

  return (ifft_tab_sinc[index]);
}

/*! \brief window to be used in the IFFT synthesis
 *
 * contains both an inverse Blackman-Harris and triangular window.
 *
 * \todo read X. Rodet, Ph. Depalle, "Spectral Envelopes and Inverse FFT
 * Synthesis." Proc. 93rd AES Convention, October 1992
 * \param sizeWindow the size of the window
 * \param pFWindow pointer to an array that will hold the window
 */

#define TWO_PI (M_PI*2)

void
IFFTwindow (int sizeWindow, float *pFWindow)
{

  int i;
  float a0 = .35875, a1 = .48829, a2 = .14128, a3 = .01168;
  double fConst = TWO_PI / sizeWindow, fIncr = 2.0 / sizeWindow, fVal = 0;

  /* compute inverse of Blackman-Harris 92dB window */
  for (i = 0; i < sizeWindow; i++)
    {
      pFWindow[i] = 1 / (a0 - a1 * cos (fConst * i) +
			 a2 * cos (fConst * 2 * i) -
			 a3 * cos (fConst * 3 * i));
    }

  /* scale function by a triangular */
  for (i = 0; i < sizeWindow / 2; i++)
    {
      pFWindow[i] = fVal * pFWindow[i] / 2.787457;
      fVal += fIncr;
    }
  for (i = sizeWindow / 2; i < sizeWindow; i++)
    {
      pFWindow[i] = fVal * pFWindow[i] / 2.787457;
      fVal -= fIncr;
    }
}



IFFTOsc::IFFTOsc ()
{
  IFFTwindow (FFT_SIZE, window);
  for (int o = 0; o < N_OSC; o++)
    {
      phase[o] = 0;
      amp[o] = 0;
      frq[o] = 0;
    }
  spectrum = new fftw_complex[FFT_SIZE];
  waveform = new double[FFT_SIZE];
  inverse_c2r =
    fftw_plan_dft_c2r_1d (FFT_SIZE, spectrum, waveform, FFTW_ESTIMATE);
  for (int k = 0; k < FFT_SIZE / 2; k++)
    {
      rover[k] = 0;
      output_buffer[k] = 0;
    }
}


void
IFFTOsc::processOneFrame ()
{
  for (int k = 0; k < FFT_SIZE / 2+1; k++)
    {
      spectrum[k][0] = 0;
      spectrum[k][1] = 0;
    }

  for (int o = 0; o < N_OSC; o++)
    {
      if (amp[o] > 0 && frq[o] > 0 && frq[o]<fs/2)	//TODO -- check frequency is at right level 
	{
	  double samplingPeriod = 1.0 / fs;
	  double sizeSpec = FFT_SIZE / 2;
	  phase[o] = phase[o] + 2 * M_PI * frq[o] * samplingPeriod * sizeSpec;

	  double loc = FFT_SIZE * frq[o] * samplingPeriod;
	  int firstBin = (int) loc - 3;
	  double binRemainder = loc - floor (loc);

	  int sizeMag = FFT_SIZE/2;

	  int k, l, b;
	  for (k = 1, l = firstBin; k <= 8; k++, l++)
	    {
	      double index = (k - binRemainder);
	      if (index > 7.999)
		index = 0;


	      double scale = ifft_sinc (index);


	      double real = cos (phase[o]);
	      double imag = sin (phase[o]);

	      if (l > 0 && l < sizeSpec)
		{
		  spectrum[l][1] += 0.5 * amp[o] * scale * imag;	//cos
		  spectrum[l][0] += 0.5 * amp[o] * scale * real;	//sin
		}
	      else if (l == 0)
		{
		  spectrum[l][0] += 0.5 * amp[o] * scale * real;	//sin
		}
	      else if (l < 0)
		{
		  b = abs (l);
		  //pSynthParams->pSpectra[b * 2 + 1] -= fNewMag * fCos;
		  //pSynthParams->pSpectra[b * 2] += fNewMag * fSin;
		  spectrum[b][1] -= 0.5 * amp[o] * scale * imag;	//cos
		  spectrum[b][0] += 0.5 * amp[o] * scale * real;	//sin	
		}
	      else if (l > sizeMag)
		{
		  b = sizeMag - (l - sizeMag);

		  spectrum[b][1] -= 0.5 * amp[o] * scale * imag;	//cos
		  spectrum[b][0] += 0.5 * amp[o] * scale * real;	//sin	
		  //pSynthParams->pSpectra[b * 2 + 1] -= fNewMag * fCos;
		  //pSynthParams->pSpectra[b * 2] += fNewMag * fSin;
		}
	      else if (l == sizeMag)
		{
		  spectrum[l][0] += 0.5 * amp[o] * scale * real;	//sin
		}
	    }


	}


    }



  fftw_execute (inverse_c2r);

  for (int k = 0; k < FFT_SIZE / 2; k++)
    {
      output_buffer[k] = waveform[k + FFT_SIZE / 2] * window[k] + rover[k];
    }
  for (int k = 0; k < FFT_SIZE / 2; k++)
    {
      rover[k] = waveform[k] * window[k + FFT_SIZE / 2];
    }

}


#if 0
int
main ()
{
  SF_INFO info;
  info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
  info.channels = 1;
  info.samplerate = 44100;

  // Open sound file for writing
  SNDFILE *outfile = sf_open ("outfile.wav", SFM_WRITE, &info);





  IFFTOsc osc;


  osc.amp[0] = 0.5;
  osc.frq[0] = 440;
  osc.fs = 44100;

  for (int i = 0; i < 5000; i++)
    {
      osc.processOneFrame ();
      sf_write_double (outfile, osc.output_buffer, FFT_SIZE / 2);
    }

  sf_close (outfile);




}
#endif
